#ifndef _FLUID_SIMULATOR_H_
#define _FLUID_SIMULATOR_H_

#include <rfftw.h>

class FluidSimulator
{
public:
	FluidSimulator(void);
	~FluidSimulator(void);

	void InitSimulator( int size, fftw_real visc );
	void InitFFT();
	void r2cFFT( fftw_real** u );
	void c2rFFT( fftw_real** u );
	void AddExternalForce();
	void VelocityAdvection();
	void DensityAdvection();
	void VelocitySwap();
	void VelocityNormalize();
	void DiffussionProjection();
	inline int floor( fftw_real x ){ return (x)>=0.0?((int)(x)):(-((int)(1-(x)))); };

	void Update(fftw_real timestep);
	void UpdateVelocity();
	void UpdateDensity();

public:

	fftw_real* u;
	fftw_real* v;
	fftw_real* u_old;
	fftw_real* v_old;
	fftw_real* d;
	fftw_real* d_old;
	fftw_real* f2u;
	fftw_real* f2v;

	rfftwnd_plan r2c;
	rfftwnd_plan c2r;

	fftw_real visc;
	fftw_real dt;

	int scale;
};

#endif
